from ise_api_0_login_info import username, password, url_prefix, headers
import requests
from requests.auth import HTTPBasicAuth
from ise_api_1_user_getall import get_user_detail
import urllib3
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)


# 修改ISE内部用戶狀態
def change_internal_user_status(user, status=False):
    user_data_dict = {"enabled": status}
    user_detail = get_user_detail(user)
    user_url = user_detail.get('url')
    user_data_dict['name'] = user_detail.get('username')
    user_data_dict['id'] = user_detail.get('id')
    r = requests.put(user_url,
                     auth=HTTPBasicAuth(username, password),
                     headers=headers,
                     json={"InternalUser": user_data_dict},
                     verify=False)


if __name__ == '__main__':
    change_internal_user_status('iseuser', status=False)